/*
 * @Description: 我的
 * @Author: admin
 * @Date: 2021-06-11 10:32:44
 * @LastEditors: admin
 * @LastEditTime: 2021-06-11 18:11:51
 */
import React from 'react';
import { Modal, Button } from 'antd'
class My extends React.Component {
  constructor(props) {
    super(props);
    this.state = {
      modalVisible: false,
    }
  }

  render () {

    const showModal = () => {
      this.setState({
        modalVisible: true
      })
    };

    const handleOk = () => {
      this.setState({
        modalVisible: false
      })
      console.log(this.state.modalVisible);
      logout();
    };

    const handleCancel = () => {
      this.setState({
        modalVisible: false
      })
    };
    const logout = () => {
      window.sessionStorage.removeItem('user')
      window.location.reload()
    };
    return (
      <div>
        {this.state.modalVisible}
        <h2>我的</h2>

        <Button type="primary" onClick={showModal}>
          退出
      </Button>
        <Modal title="提示：" visible={this.state.modalVisible
        } onOk={handleOk} onCancel={handleCancel}>
          <p>确定要退出账号吗？</p>
        </Modal>
      </div>
    )
  }
}

export default My